#{extends 'backend_main.html' /}
#{set title:'登录' /}
<body class="login-bg">
<div class="login">
    <div class="message">管理员登录</div>
    <div id="darkbannerwrap"></div>
    <form method="post" class="layui-form" >
        <input name="username" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" >
        <hr class="hr15">
        <input name="password" lay-verify="required" placeholder="密码"  type="password" class="layui-input">
        <hr class="hr15">
        <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
        <hr class="hr20" >
    </form>
</div>
<script>
    $(function  () {
        layui.use('form', function(){
            var form = layui.form;
            //监听提交
            form.on('submit(login)', function(data){
                layer.msg("正在登录...");
                $.ajax({
                    type:"POST",                      //请求类型
                    url:"./login",                 //URL
                    data:data.field,                  //传递的参数
                    dataType:"json",                 //返回的数据类型
                    success:function(data){          //data就是返回的json类型的数据
                        console.log(JSON.stringify(data));
                        if(data.code=="1"){
                            location.href='/BackendLogin/backendmain';
                        }else{
                            layer.msg(data.msg,function(){
                                window.location.reload();
                            });
                        }
                    },
                    error:function(data){
                    }
                });
                return false;
            });
        });
    });
    if (self!=top){
        window.top.location.replace(self.location); //打开自己网站的页面
    }
</script>
</body>